package com.xiaoy.core.basic.organization.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.xiaoy.util.store.config.ConfigTable;

@Entity
@Table(name=ConfigTable.Basic.PARTYTYPE)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@SequenceGenerator(name=ConfigTable.Basic.PARTYTYPE+"_SEQ",sequenceName=ConfigTable.Basic.PARTYTYPE+"_SEQ",allocationSize=1)
public class PartyType implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private List<Party>partys = new ArrayList<Party>();
	
	private String name;

	private long id;
	
	private long priority;
	
	public PartyType () {}
	
	public PartyType (String name) {
		this.name = name;
	}
	
	public PartyType (String name,long priority) {
		this(name);
		this.priority = priority;
	}
	

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "BAS_ORG_PARTYTYPE_SEQ")
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}
	
	@OneToMany(cascade = { CascadeType.ALL }, mappedBy = "partyType")
	@Fetch(FetchMode.SUBSELECT)
	public List<Party> getPartys() {
		return partys;
	}

	public void setPartys(List<Party> partys) {
		this.partys = partys;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public long getPriority() {
		return priority;
	}

	public void setPriority(long priority) {
		this.priority = priority;
	}
	
	
}
